[//

async function( kuo,Context,context){
    let LANG = this.LANG();
    let $DATA = Object.assign({},this.$DATA);
    let $hash = 'safetoken/'+kuo.adminid;
    $DATA.token = Mode("Tools").Uuid();
    await Mem.Set($hash,$DATA.token);
    let  $kongzhi = kuo.Path.length > 0?kuo.Path[kuo.Path.length-1]:"get";
    let  $db = await db('admin');
    let  $_GET = kuo.get;
    let  $_POST = kuo.post;
    let  $features = await Kuoplus(kuo.class);
    let  $chushi = true;
    if($kongzhi == 'get'){
        let $page = Mode("Tools").Int($_GET['page']?$_GET['page']:1);
        let $limitx  =  Mode("Tools").Int($_GET['limit']?$_GET['limit']:10);
        if($limitx < 10 ){
            $limitx = 10;
        }else if($limitx > 100 ){
            $limitx = 100;
        }
        let $Where ={};
        let $data  = await $db.Where($Where).Limit($limitx,$page).Order("id desc").Select();
        let $total = await $db.Where($Where).Total();
        if(!$data){
            $data= [];
        }
        $DATA.code = 0;
        $DATA.count = $total;
        if($page == 1 && $chushi){
            $DATA.verifyip =$features['configure']['verifyip'];
            $DATA.off = $features['configure']['off'];
            $DATA.groups = await Kuo_admin.Groups();
        }
        $DATA.data = $data;

    }else if($kongzhi == 'put'){
       
        let $id = Mode("Tools").Int($_POST['id']?$_POST['id']:0);
        let $data = await $db.Where({id: $id}).Find();

        if(!$data){
            $DATA.code = -1;
            $DATA.msg = LANG.admin_id_no;
            Context.body = JSON.stringify($DATA);
            return ;
        }

        let $update = {
            'groups':Mode("Tools").Int($_POST['groups']),
            'off':Mode("Tools").Int($_POST['off']),
            'verifyip':Mode("Tools").Int($_POST['verifyip'])
        }

        if($data['id'] == kuo.adminid){
            $update['off'] = 1;
        }
        if(  $_POST['password'] && $_POST['password'] != ""){
            $update['password'] = Kuomm($_POST['password']);
        }
        if( $_POST['sessionid'] && $_POST['sessionid'] != ""){
            $update['sessionid'] = Kuomm(Mode("Tools").Uuid());
        }
        let $fan = await $db.Where({id: $id}).Update($update);
        if($fan){
            let $huoqu = await  $db.Where({'off':1,'groups':'0'}).Find();
            if(!$huoqu){
                $update['off'] = 1;
                $update['groups'] = 0;
                await $db.Where({id: $id}).Update($update);
            }
            await Adminid($id,1);
            await Kuolog('adminlog',kuo.adminid,3,{'yuan':$data,'data':$update},kuo.func_,kuo.class,kuo.ip);
            $DATA.data = $update;
            $DATA.code =1;
            $DATA.msg = LANG.put_ok;
        }else{
            $DATA.code =-1;
            $DATA.msg = LANG.put_no;
        }

    }else if($kongzhi == 'add'){

        let $data = await $db.Where({'account':$_POST['account']}).Find();
        if($data){
            $DATA.code = -1;
            $DATA.msg = LANG.admin_id_ok;
            Context.body = JSON.stringify($DATA);
            return ;
        }
        let $insert = {
            'account':$_POST['account'],
            'password':Kuomm($_POST['password']),
            'groups':$_POST['groups'],
            'verifyip':$_POST['verifyip'],
            'off':$_POST['off'],
            'ip':kuo.ip,
            'atime':Mode("Tools").Time()
        };
        let $fan = await $db.Insert($insert);
        if($fan){
            $DATA.code = 1;
            $DATA.msg = LANG.add_ok;
            await Kuolog('adminlog',kuo.adminid,4, $insert ,kuo.func_,kuo.class,kuo.ip);
        }else{
            $DATA.code = -1;
            $DATA.msg = LANG.add_no;
        }

    }else if($kongzhi == 'del'){

        let $id = Mode("Tools").Int($_POST['id']?$_POST['id']:0);
        let $data = await $db.Where({id: $id}).Find();

        if(!$data){
            $DATA.code = -1;
            $DATA.msg = LANG.admin_id_no;
            Context.body = JSON.stringify($DATA);
            return ;
        }

        let $huoqu = await $db.Where({'off':1,'groups':'0'}).Select();
        if(!$huoqu){
            $DATA.code = -1;
            $DATA.msg = LANG.admin_user_no;
            Context.body = JSON.stringify($DATA);
            return ;
        }

        if($huoqu.length == 1){
            if($huoqu['0']['id'] == $id){
                $DATA.code = -1;
                $DATA.msg = LANG.admin_user_no;
                Context.body = JSON.stringify($DATA);
                return ;
            }
        }

        let $fan = await $db.Where({id: $id}).Delete();
        if($fan){
            await Adminid($id,2);
            await Kuolog('adminlog',kuo.adminid,5, $data ,kuo.func_,kuo.class,kuo.ip);
            $DATA.code = 1;
            $DATA.msg = LANG.del_ok;
        }else{
            $DATA.code = -1;
            $DATA.msg = LANG.del_no;
        }
    }
    Context.body = JSON.stringify($DATA);
}

]